FROM busybox as builder
# 工作目录
WORKDIR /tmp
# 构建参数
ARG ghaddr=http://github.com \
    ghuser=Mrs4s \
    ghproj=go-cqhttp \
    tag=1.0.0-rc3
# 开始构建
RUN export TARGETARCH=$(uname -m|sed s/aarch64/arm64/g|sed s/armv7l/arm/g|sed s/x86_64/amd64/g) && \
    echo "downloading ${ghaddr}/${ghuser}/${ghproj}/releases/download/v${tag}/${ghproj}_linux_${TARGETARCH}.tar.gz" && \
    wget -O- "${ghaddr}/${ghuser}/${ghproj}/releases/download/v${tag}/${ghproj}_linux_${TARGETARCH}.tar.gz" | tar -xz "${ghproj}"
RUN mv "/tmp/${ghproj}" /tmp/app && mkdir workdir
# 准备打包
FROM alpine
# 工作目录
VOLUME [ "/workdir" ]
WORKDIR /workdir
# 主程序
COPY --from=builder /tmp/app /app
# 为了支持任意格式的语音发送, 需要安装 ffmpeg 。
RUN apk add ffmpeg --no-cache && rm -rf /var/cache/* /var/log/* /tmp/* /root/*
# 加入默认配置
ADD ./workdir /workdir
# 系统端口
EXPOSE 5700 8080
# 启动参数
ENTRYPOINT [ "/app" ]
CMD [ "-faststart" ]